package com.shy.userservice.config;

import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.shy.userservice.utils.CodeGenerator;
import com.shy.userservice.utils.PasswordGenerator;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author RinMi
 * @since 2022/11/23/2:53 PM
 */
@EnableTransactionManagement
@MapperScan("com.shy.userservice.mapper")
@Configuration
public class UserServiceConfig {

    @Bean
    public ISqlInjector sqlInjector() {
        return new LogicSqlInjector();
    }
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    @Value("${codeBit}")
    private Integer codeBit;

    @Bean
    public CodeGenerator codeGenerator(){
        return new CodeGenerator(codeBit);
    }

    @Value("${passwordBit}")
    private Integer passwordBit;

    @Bean
    public PasswordGenerator passwordGenerator(){
        return new PasswordGenerator(passwordBit);
    }

}
